package com.wlyuan.open.domain.api.factory;

import com.wlyuan.open.domain.api.OpenApi;
import com.wlyuan.open.domain.api.assembler.OpenApiAssembler;
import com.wlyuan.open.domain.api.respository.OpenApiRepository;
import com.wlyuan.open.dto.api.OpenApiCreationDTO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import lombok.var;
import org.springframework.stereotype.Service;

/**
 * @author lijing
 * @description
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class OpenApiFactory {
    private final OpenApiRepository openApiRepository;

    public OpenApi create(OpenApiCreationDTO creationDTO) {
        creationDTO.setMethod(creationDTO.getMethod().toUpperCase());
        var openApi = OpenApiAssembler.assemble(creationDTO);
        openApiRepository.save(openApi);
        return openApi;
    }

}
